home *** CD-ROM | disk | FTP | other *** search
/ Just Call Me Internet / Just Call Me Internet.iso / prog / atari / c / stut_src / rshremap.c < prev    next >
Text File  |  1996-05-27  |  5KB  |  164 lines

  1. /*
  2.  * rshremap.c
  3.  *
  4.  *        .RSH file Remap Utility
  5.  *        Copyright (c)1993 by Fran‡ois PLANQUE
  6.  *
  7.  * Purpose:
  8.  * --------
  9.  * Remaps .RSH files in memory
  10.  *
  11.  * History:
  12.  * --------
  13.  * 1993: fplanque: Created
  14.  */
  15.  
  16.  
  17.      #include "!OPTIONS.H"                /* Options de compilation */         
  18.           
  19.  
  20. /*
  21.  * System headers:
  22.  */
  23.     #include    <aes.h>            /* D‚finitions AES standard:            
  24.                                      * OBJECT, TEDINFO, etc...
  25.                                      * rsrc_obfix()...
  26.                                      */
  27.     #include    "rsh_map.h"        /* Definition du type RSH_MAP
  28.                                      * Inclure dans le module contenant
  29.                                      * le .RSH, le fichier RSHCRMAP.H
  30.                                      * qui se charge de cr‚er un
  31.                                      * rsh_map associ‚...
  32.                                      */
  33.    
  34. /*
  35.  * ------------------------ FUNCTIONS -------------------------
  36.  */
  37.  
  38. /*
  39.  * remap_rsh(-)
  40.  *
  41.  * Purpose:
  42.  * --------
  43.  * Routine de relocation
  44.  *
  45.  * Notes:
  46.  * ------
  47.  * Cette routine va reloger la ressource en m‚moire.
  48.  *    Attention: si le compilateur r‚unit les chaines de caractŠres
  49.  * identiques en compilant le module contenany le fichier RSH,
  50.  *    il y a risque de bobo!
  51.  *
  52.  * History:
  53.  * --------
  54.  * 1993: fplanque: Created
  55.  * 01.02.95: ne reloge plus les pointeurs sur bitmaps (iconblk et bitblk), il est en effet possible de les fixer directement dans le .RSH
  56.  */
  57. void    remap_rsh( RSH_MAP *rsh_map )
  58. {
  59.  
  60.     int    i;                                    /* Pour les boucles */
  61.  
  62.     /****************************************************/
  63.     /* Relocation des objets: (en particulier: OB_SPEC) */
  64.     /****************************************************/
  65.     if ( rsh_map -> num_obs )
  66.     {
  67.         /* Parcourt les objets: */
  68.         for( i = 0; i < rsh_map -> num_obs; i++ )
  69.         {
  70.             /* Conversion coordonn‚es */
  71.             rsrc_obfix( &( (rsh_map -> rs_object)[ i ] ), 0 );
  72.             
  73.             /* Relocation de OB_SPEC: */
  74.             switch( (rsh_map -> rs_object)[ i ] .ob_type )    /* Type de l'objet */
  75.             {
  76.                 case    G_BOX:
  77.                 case    G_IBOX:
  78.                 case    G_BOXCHAR:
  79.                 /* OBSPEC n'est pas un pointeur */
  80.                     break;
  81.                     
  82.                 case    G_TEXT:
  83.                 case    G_BOXTEXT:
  84.                 case    G_FTEXT:
  85.                 case    G_FBOXTEXT:
  86.                 /* OBSPEC Pointe sur TEDINFO: */
  87.                     (rsh_map -> rs_object)[ i ] .ob_spec.tedinfo =
  88.                         &(rsh_map -> rs_tedinfo)[ (rsh_map -> rs_object)[ i ] .ob_spec.index ];
  89.                     break;
  90.  
  91.                 case    G_IMAGE:
  92.                 /* OBSPEC Pointe sur BITBLK: */
  93.                     (rsh_map -> rs_object)[ i ] .ob_spec.bitblk =
  94.                         &(rsh_map -> rs_bitblk)[ (rsh_map -> rs_object)[ i ] .ob_spec.index ];
  95.                     break;
  96.  
  97.                 case    G_USERDEF:
  98.                 /* OBSPEC Pointe sur USERBLK: */
  99.                     break;
  100.  
  101.                 case    G_BUTTON:
  102.                 case    G_STRING:
  103.                 case    G_TITLE:
  104.                 /* OBSPEC Pointe sur STRING: */
  105.                     (rsh_map -> rs_object)[ i ] .ob_spec .free_string =
  106.                         (rsh_map -> rs_strings)[ (rsh_map -> rs_object)[ i ] .ob_spec .index ];
  107.                     break;
  108.                     
  109.                 case    G_ICON:
  110.                 /* OBSPEC Pointe sur ICONBLK: */
  111.                     (rsh_map -> rs_object)[ i ] .ob_spec.iconblk =
  112.                         &(rsh_map -> rs_iconblk)[ (rsh_map -> rs_object)[ i ] .ob_spec.index ];
  113.                     break;
  114.                     
  115.                 default:
  116.                     break;
  117.             }
  118.         }
  119.     }
  120.  
  121.  
  122.     /****************************/
  123.     /* Relocation des tedinfos: */
  124.     /****************************/
  125.     if ( rsh_map -> num_ti )
  126.     {
  127.     /* Parcourt les objets: */
  128.         for( i = 0; i < rsh_map -> num_ti; i++ )
  129.         {
  130.         /* Reloge pointeur sur ptext: */
  131.             (rsh_map -> rs_tedinfo)[ i ] .te_ptext =
  132.                 (rsh_map -> rs_strings)[ (int) (rsh_map -> rs_tedinfo)[ i ] .te_ptext ];
  133.         /* Reloge pointeur sur ptmplt: */
  134.             (rsh_map -> rs_tedinfo)[ i ] .te_ptmplt =
  135.                 (rsh_map -> rs_strings)[ (int) (rsh_map -> rs_tedinfo)[ i ] .te_ptmplt ];
  136.         /* Reloge pointeur sur pvalid: */
  137.             (rsh_map -> rs_tedinfo)[ i ] .te_pvalid =
  138.                 (rsh_map -> rs_strings)[ (int) (rsh_map -> rs_tedinfo)[ i ] .te_pvalid ];
  139.                 /*        printf("%lu\n",(rsh_map -> rs_tedinfo)[ i ] .te_pvalid); */
  140.         }
  141.     }
  142.  
  143.     /******************************/
  144.     /* Relocation des IconBlocks: */
  145.     /******************************/
  146.     if ( rsh_map -> num_ib )
  147.     {
  148.     /* Parcourt les objets: */
  149.         for( i = 0; i < rsh_map -> num_ib; i++ )
  150.         {
  151.         /* Reloge pointeur sur pmask: */
  152.         /*    (rsh_map -> rs_iconblk)[ i ] .ib_pmask =
  153.         /*        (rsh_map -> rs_imdope)[ (int) (rsh_map -> rs_iconblk)[ i ] .ib_pmask ] .image; */
  154.         /* Reloge pointeur sur pdata: */
  155.         /*    (rsh_map -> rs_iconblk)[ i ] .ib_pdata =
  156.         /*        (rsh_map -> rs_imdope)[ (int) (rsh_map -> rs_iconblk)[ i ] .ib_pdata ] .image; */
  157.         /* Reloge pointeur sur ptext: */
  158.             (rsh_map -> rs_iconblk)[ i ] .ib_ptext =
  159.                 (rsh_map -> rs_strings)[ (int) (rsh_map -> rs_iconblk)[ i ] .ib_ptext ];
  160.         }
  161.     }
  162.  
  163. }
  164.